import { defineStore } from 'pinia'
import request from '@/utils/request'
import { ApiRes, Branditem, homeitem, HomeProduct, hotitem, newitem, specialitem } from '@/views/types/data'



export default defineStore('home',{

  state(){
    return{
     homelist:[] as homeitem[],
     newList:[] as newitem[],
     hotGoodList:[] as hotitem[],
     brandList:[] as Branditem[],
     goodsList:[] as HomeProduct[],
     speciaList:[] as specialitem[]
    }
  },
  actions: {
   async gethomeList(){
    const res = await request.get<ApiRes<homeitem[]>>('/home/banner')
      //  console.log(res);
       this.homelist = res.data.result
    },
    async getnewList(){
    const res = await request.get<ApiRes<newitem[]>>('/home/new')
    this.newList = res.data.result
    },
    async gethotlist(){
     const res = await request.get<ApiRes<hotitem[]>>('/home/hot')

    //  console.log(res);
     
     this.hotGoodList = res.data.result
    },
    async getbrandlist(){
         const res = await request.get<ApiRes<Branditem[]>>('/home/brand')
        //  console.log(res);
     this.brandList = res.data.result
    },
  async getgoodslist(){
      const res = await request.get<ApiRes<HomeProduct[]>>('/home/goods')
      // console.log(res);
      this.goodsList = res.data.result
  },
  async getspeciallist(){
    const res = await request.get<ApiRes<specialitem[]>>('/home/special')
    // console.log(res);
    this.speciaList = res.data.result
    
  }


  }

  
})